using System;
using System.Collections.Generic;
using System.Text;

using System.Drawing;
using System.Windows.Forms;
using Microsoft.HomeServer.Extensibility;
using System.Reflection;

namespace Microsoft.HomeServer.HomeServerConsoleTab.WhsPhotoUploadTab
{
    // The class declaration
    // Take note!  This class is how the WHS Server Console interfaces with your
    // application.  Your app's UI details for the WHS Server Console to render
    // is via this class.
    //
    // More details can be found at the WHS SDK:
    //   http://msdn2.microsoft.com/en-us/library/aa306570.aspx
    //
    public class HomeServerTabExtender : Microsoft.HomeServer.Extensibility.IConsoleTab
    {
        // Private vars --------------
        private int width;
        private int height;
        private IConsoleServices services;
        private Control tabControl;     // This var will hold the UI for the tab built in the constructor

        // Properties ----------------
        
        // Required: Returns the app's WHS Server Console Tab's text
        public string TabText
        {
            get
            {
                return ("WHS Photo Upload");
            }
        }

        // Required: Returns the app's WHS Server Console Tab's image
        public Bitmap TabImage
        {
            get
            {
                // TODO: Provide details on how this works
                return new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("Microsoft.HomeServer.HomeServerConsoleTab.WhsPhotoUploadTab.Images.logo.png"));
            }
        }

        // Required: Returns the app's WHS Server Console Tab's content panel (this is where the UI is)
        public Control TabControl
        {
            get
            {
                // You want to return the control that was built ONCE.  You do not want to create a new UI 
                // everytime this is called.  This will cause LOTS of problems.
                return (tabControl);
            }
        }

        // Required: Returns if you want to use custom help
        public bool GetHelp()
        {
            return false;
        }

        // Required: Returns a GUID if you plan on using WHS for keeping track of settings
        public Guid SettingsGuid
        {
            get
            {
                return Guid.Empty;
            }
        }


        // The constructor
        public HomeServerTabExtender(int width, int height, IConsoleServices consoleServices)
        {
            this.width = width;
            this.height = height;
            this.services = consoleServices;

            // This is where we build the new tab panel's UI

            // We're wrapping this area with a try/catch block to catch any
            // execeptions we missed in the our tab extension. This prevents
            // the extension from simply "not showing up" should there be an error
            try
            {
                tabControl = new MainTabPanel();
                tabControl.Width = width;
                tabControl.Height = height;
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.ToString(), "Whs Photo Upload", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            
        }
    }


}
